using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Serialization;

namespace Belmost4PDA.DatabaseWorkPDA
{
    public class XmlQueryLoader
    {
        public class SavedData
        {
            [SoapAttribute]
            public List<DataRows.DataRows> rows;
        }
        public static string RowsToXMLString(List<DataRows.DataRows> rows)
        {
            SavedData sd = new SavedData();
            sd.rows = rows;
            XmlSerializer xml1 = new XmlSerializer(typeof(DataRows.DataField));
            XmlSerializer xml2 = new XmlSerializer(typeof(DataRows.DataRows));
            XmlSerializer xml = new XmlSerializer(typeof(SavedData));
            StringBuilder builder = new StringBuilder("");
            StringWriter sw = new StringWriter(builder);
            xml.Serialize(sw, sd);
            return builder.ToString();
        }
        public static List<DataRows.DataRows>XMLStringToRows(string Xml)
        {
            SavedData sd;
            XmlSerializer xml = new XmlSerializer(typeof(SavedData));
            StringReader reader = new StringReader(Xml);
            sd = (SavedData)(xml.Deserialize(reader));
            return sd.rows;
        }

    }
}
